﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.UI.WebControls;
using Medianamik.Core;
using Medianamik.UI.Web.MVP.View;

namespace Medianamik.UI.Web.Membership.Views
{
    public partial class UserList : ModuleViewWithGrid<IUserList>, IUserList
    {
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            FilterButton.Click += OnFilterButton;
        }

        void OnFilterButton(object sender, EventArgs e)
        {
            OnFilter();
        }

        public override string TypeSelectorUrl
        {
            get
            {
                return MembershipPages.GroupSelector;
            }
        }

        public override IMedianamikGrid Grid
        {
            get { return UserGrid; }
        }

        public override HyperLink AddButton
        {
            get { return AddUserButton; }
        }

        public override string ListingPageUrl
        {
            get { return MembershipPages.UserList; }
        }

        public override IEnumerable<ListItem> Status
        {
            get { return ContentStatesList.Items.Cast<ListItem>(); }
            set { ContentStatesList.Items.AddRange(value.ToArray()); }
        }

        public override string Keywords
        {
            get { return Name.Text; }
            set { Name.Text = value; }
        }

        public override string EditPageUrl
        {
            get
            {
                return MembershipPages.UserEdit;
            }
        }

        public override Guid BaseTypeId
        {
            get
            {
                return MembershipTypeIds.UserProfile;
            }
        }

        public override Guid ModuleNodeId
        {
            get
            {
                return MedianamikModules.SecurityManagement;
            }
        }

        public override string BreadcrumbTrail
        {
            get { return Breadcrumbs.Text; }
            set { Breadcrumbs.Text = value; }
        }

        public virtual IEnumerable<ListItem> Groups
        {
            get { return GroupList.Items.Cast<ListItem>(); }
            set { GroupList.Items.AddRange(value.ToArray()); }
        }
    }

    public interface IUserList : IModuleViewWithGrid
    {
        IEnumerable<ListItem> Groups { get; set; }
    }
}
